-- DROP TABLE vol_character;

CREATE TABLE vol_character
(
  code character varying(20) NOT NULL,
  chara_name character varying(20),
  CONSTRAINT pk_chara PRIMARY KEY (code)
)
WITH (
  OIDS=FALSE
);


-- DROP TABLE vol_figure;

CREATE TABLE vol_figure
(
  code character varying(30) NOT NULL,
  "name" character varying(50),
  CONSTRAINT pk_code PRIMARY KEY (code)
)
WITH (
  OIDS=FALSE
);

-- DROP TABLE vol_figure_details;

CREATE TABLE vol_figure_details
(
  id_details integer NOT NULL DEFAULT nextval('vol_character_details_id_details_seq'::regclass),
  vol_figure_code character varying(30),
  code character varying(30),
  "desc" character varying(150),
  CONSTRAINT pk_id PRIMARY KEY (id_details)
)
WITH (
  OIDS=FALSE
);

-- DROP TABLE vol_figure_kline_daily_map;

CREATE TABLE vol_figure_kline_daily_map
(
  stock_code character varying(10) NOT NULL,
  stock_date_start date NOT NULL,
  stock_date_end date,
  id_vol_figure_details integer,
  CONSTRAINT pk_vol_figure_kline_daily PRIMARY KEY (stock_code, stock_date_start)
)
WITH (
  OIDS=FALSE
);

CREATE TABLE vol_character_details
(
  id_details integer NOT NULL DEFAULT nextval('vol_figure_details_id_details_seq'::regclass),
  vol_character_code character varying(30),
  code character varying(30),
  proc_class_name character varying(200) NOT NULL,
  pattern text,
  CONSTRAINT pk_vol_character_details_id PRIMARY KEY (id_details)
)
WITH (
  OIDS=FALSE
);


-- DROP TABLE vol_character_kline_daily;

CREATE TABLE vol_character_kline_daily
(
  id_vol_charac_details integer NOT NULL,
  stock_code character varying(30) NOT NULL,
  start_date date NOT NULL,
  end_date date,
  inst_pattern text,
  CONSTRAINT pk_vol_chara_details_kaily_line PRIMARY KEY (id_vol_charac_details, stock_code, start_date)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE vol_character_kline_daily OWNER TO vison;
